Skip to content

[FIX] HW reset recovery regression - #365

Merged
ymodlin merged 1 commit into
devfrom
fix-hw-reset-regression
Feb 19, 2026
Merged

[FIX] HW reset recovery regression#365
ymodlin merged 1 commit into
devfrom
fix-hw-reset-regression

Conversation

@Nikolai-L

Copy link
Copy Markdown
Contributor

[FIX] HW reset recovery regression

Copilot AI review requested due to automatic review settings February 19, 2026 10:30
@Nikolai-L
Nikolai-L requested a review from ymodlin February 19, 2026 10:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds cleanup logic before hardware reset to address a regression in HW reset recovery. The fix ensures that SERDES pipes are properly released and cached sensor values are reset before initiating a hardware reset on D4XX camera devices.

Changes:

  • Added pre-reset cleanup that resets cached sensor values and releases configured SERDES pipes
  • Iterates through all four sensors (depth, IR, RGB, IMU) to clear cached values and release pipes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread kernel/realsense/d4xx.c
Comment on lines +2273 to +2279
} else {
int release_ret = max9296_release_pipe(state->dser_dev,
sensor->pipe_id);
dev_warn(&state->client->dev, "release pipe %d (%d)\n",
sensor->pipe_id, release_ret);
sensor->pipe_configured = false;
}

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The else clause at line 2273 is redundant. Since the if block at line 2271-2272 uses continue, the else is unnecessary and makes the code less readable. The code within the else block can be unindented to the same level as the if statement. This follows standard best practices for early returns/continues to reduce nesting.

Suggested change
} else {
int release_ret = max9296_release_pipe(state->dser_dev,
sensor->pipe_id);
dev_warn(&state->client->dev, "release pipe %d (%d)\n",
sensor->pipe_id, release_ret);
sensor->pipe_configured = false;
}
}
int release_ret = max9296_release_pipe(state->dser_dev,
sensor->pipe_id);
dev_warn(&state->client->dev, "release pipe %d (%d)\n",
sensor->pipe_id, release_ret);
sensor->pipe_configured = false;

Copilot uses AI. Check for mistakes.
Comment thread kernel/realsense/d4xx.c
Comment on lines +2274 to +2275
int release_ret = max9296_release_pipe(state->dser_dev,
sensor->pipe_id);

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is calling max9296_release_pipe directly instead of using the interface abstraction pattern (state->dser_ops->release_pipe). This is inconsistent with the pattern used later in the same function at lines 2376-2377, which uses state->dser_ops->release_pipe. Direct calls bypass the interface abstraction and will fail if the deserializer is a MAX96712 instead of MAX9296. The code should use state->dser_ops->release_pipe to support both deserializer types.

Suggested change
int release_ret = max9296_release_pipe(state->dser_dev,
sensor->pipe_id);
int release_ret = state->dser_ops->release_pipe(state->dser_dev,
sensor->pipe_id);

Copilot uses AI. Check for mistakes.
Comment thread kernel/realsense/d4xx.c
Comment on lines +2259 to +2282
if (state->dser_dev) {
mutex_lock(&serdes_lock__);
for (i = 0; i < ARRAY_SIZE(sensors); i++) {
struct ds5_sensor *sensor = sensors[i];

sensor->cached_dt_value = 0xFFFF;
sensor->cached_md_value = 0xFFFF;
sensor->cached_override_value = 0xFFFF;
sensor->cached_fps_value = 0xFFFF;
sensor->cached_width_value = 0xFFFF;
sensor->cached_height_value = 0xFFFF;

if (!sensor->pipe_configured) {
continue;
} else {
int release_ret = max9296_release_pipe(state->dser_dev,
sensor->pipe_id);
dev_warn(&state->client->dev, "release pipe %d (%d)\n",
sensor->pipe_id, release_ret);
sensor->pipe_configured = false;
}
}
mutex_unlock(&serdes_lock__);
}

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new code block is not wrapped in CONFIG_VIDEO_D4XX_SERDES conditional compilation guards, unlike the similar block at lines 2357-2392. The code accesses SERDES-specific fields (state->dser_dev, state->dser_ops) and uses the serdes_lock__ mutex, which are only defined when CONFIG_VIDEO_D4XX_SERDES is enabled. This will cause compilation errors when CONFIG_VIDEO_D4XX_SERDES is not defined. Wrap this code block with #ifdef CONFIG_VIDEO_D4XX_SERDES / #endif to match the pattern used elsewhere in the function.

Copilot uses AI. Check for mistakes.
@ymodlin
ymodlin merged commit 4fdddfe into dev Feb 19, 2026
12 checks passed
@ymodlin
ymodlin deleted the fix-hw-reset-regression branch February 19, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants